package cn.tedu.tedu;
//测试map接口
import java.util.HashMap;
import java.util.Map;

public class Test2 {
    public static void main(String[] args) {
        Map<Integer,String> m=new HashMap();
        System.out.println(m);
        m.put(9527,"唐伯虎");
        m.put(9528,"秋香");
        m.put(9520,"石榴姐");
        m.put(9521,"石榴姐");//v能重复
        m.put(9521,"石榴");//K不能重复否则会覆盖之前的值
        System.out.println(m);//无序//{9520=石榴姐, 9521=石榴, 9527=唐伯虎, 9528=秋香}
        //m.clear();
        System.out.println(m.containsKey(2));
        System.out.println(m.containsKey(9528));
        System.out.println(m.containsValue("xie"));
        System.out.println(m.containsValue("唐伯虎"));

        Map<Double,Integer> m1=new HashMap();
        m1.put(1.1,1);
        m1.put(1.2,2);
        m1.put(1.2,3);
        System.out.println(m.equals(m1));
        System.out.println(m.get(9520));
        System.out.println(m.hashCode());
        System.out.println(m.isEmpty());
        System.out.println(m.size());
        m.remove(9527);
        System.out.println(m);
        //从此映射中移除指定键的映射关系（如果存在）。
        System.out.println(m.remove(9521)+"~~");//移除 并返回9521对应的value值
        System.out.println(m);

        Map<Integer,String> m2=new HashMap();
        m2.put(9510,"谢");
        m.putAll(m2);//无返回值
        System.out.println(m);

    }

}
